﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DataAccess;
using System.Web.Security;
public partial class ExpertUsers_ListTask : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
           
        IDataReader Dr=null;
           var thisUser= Membership.GetUser(User.Identity.Name);
           Session["UserName"]=thisUser.UserName;
    if (!IsPostBack)
       {
           Dr=TblExpert.FetchByParameter(TblExpert.Columns.UserName, SubSonic.Comparison.Equals, Session["UserName"].ToString());
           if (Dr.Read())
           {
               
               Session["ExID"] = Dr["Id"].ToString();
           }
           Dr.Close();
       }
   
      }
    protected void BtConf_Click(object sender, EventArgs e)
    {

        //List<int> CustId = new List<int>();
        //for (int count = 0; count < GridView1.Rows.Count; count++) {
        //    DropDownList DrpConf = GridView1.Rows[count].Cells[9].FindControl("DrpConf") as DropDownList;
        if (DrpConf.SelectedValue == "0")
        {

            //        CustId.Add(Convert.ToInt32(GridView1.Rows[count].Cells[0].Text));    

            //    }

            //        foreach (int Id in CustId)
            //        {
            SubSonic.Query Qr = TblCusFolder.CreateQuery();
            Qr.QueryType = SubSonic.QueryType.Update;
            Qr.AddUpdateSetting(TblCusFolder.Columns.ExpDescription, TextBox1.Text);
            Qr.AddUpdateSetting(TblCusFolder.Columns.IsDone, 0);
            Qr.AddUpdateSetting(TblCusFolder.Columns.RecordSave, Session["ID"]);
            Qr.AddUpdateSetting(TblCusFolder.Columns.Flag,1);
            Qr.WHERE(TblCusFolder.Columns.Id, SubSonic.Comparison.Equals, Session["ID"].ToString());
            Qr.Execute();
        }
        else if (DrpConf.SelectedValue == "1")
        {
            SubSonic.Query Qr = TblCusFolder.CreateQuery();
            Qr.QueryType = SubSonic.QueryType.Update;
            Qr.AddUpdateSetting(TblCusFolder.Columns.ExpDescription, TextBox1.Text);
            Qr.AddUpdateSetting(TblCusFolder.Columns.IsDone, 1);
            Qr.AddUpdateSetting(TblCusFolder.Columns.Flag, 1);
            Qr.AddUpdateSetting(TblCusFolder.Columns.DoneDate, DateTime.Now.ToString());
            Qr.WHERE(TblCusFolder.Columns.Id, SubSonic.Comparison.Equals, Session["ID"].ToString());
            Qr.Execute();
        }

        //        }

        //}
        //foreach (int Id in CustId)
        //{
        //    SubSonic.Query Qr = TblCusFolder.CreateQuery();
        //    Qr.QueryType = SubSonic.QueryType.Update;
        //    Qr.AddUpdateSetting(TblCusFolder.Columns.ExpDescription, TextBox1.Text);
        //    Qr.AddUpdateSetting(TblCusFolder.Columns.IsDone, 1);
        //    Qr.AddUpdateSetting(TblCusFolder.Columns.DoneDate, DateTime.Now.ToString());
        //    Qr.WHERE(TblCusFolder.Columns.Id, SubSonic.Comparison.Equals, Id);
        //    Qr.Execute();

        //}
    }
        

   
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        PnlRep.Visible = true;
        int Index =Convert.ToInt32( e.CommandArgument);
        Session["ID"]=GridView1.Rows[Index].Cells[0].Text;
            
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

        GridView1.EditIndex = e.NewEditIndex;
        //Bind data to the GridView control.
        GridView1.DataBind();


    }
}
